package top.soeasy.wechat.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.core.userdetails.UsernameNotFoundException;
import org.springframework.stereotype.Service;
import top.soeasy.common.constant.Constants;
import top.soeasy.common.core.domain.entity.SysMember;
import top.soeasy.common.core.domain.entity.SysUser;
import top.soeasy.common.core.domain.model.LoginUser;
import top.soeasy.common.core.domain.model.MiniLoginMember;
import top.soeasy.common.core.redis.RedisCache;
import top.soeasy.framework.web.service.SysPermissionService;
import top.soeasy.system.service.ISysMenuService;
import top.soeasy.system.service.ISysUserService;
import top.soeasy.wechat.service.ISysMemberService;

import java.util.Map;

@Service("mobileCodeUserDetails")
public class MobileCodeUserDetailsServiceImpl implements UserDetailsService {
    @Autowired
    private ISysMemberService sysMemberService;

    @Override
    public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {
        SysMember member = sysMemberService.findMemberByMobile(username);

        return createLoginMember(member);
    }

    public UserDetails createLoginMember(SysMember member)
    {
        return new MiniLoginMember(member);
    }
}
